<?php
	$this->pageTitle = 'TweetBoard';
?>
<h3>TweetBoard</h3>
<p>Welcome to the TweetBoard! If you're on <a href="http://twitter.com">Twitter</a>, add @wmcoop to your tweets, and they'll appear here!</p>
<div class="yui-gc">
	<div class="yui-u first">
		<?php
		
		$recents = array();
		
		foreach($results['results'] as $tweet) {
			echo '<div class="tweet"><img src="', $tweet['profile_image_url'], '"/>';
			$text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $tweet['text']);
			echo $markdown->parse('[' . $tweet['from_user'] . '](http://twitter.com/' . $tweet['from_user'] .') ' . $text);
			echo '<p class="date">', date('g:i a, F jS, Y', strtotime($tweet['created_at'])), ' from ', html_entity_decode($tweet['source']), '</p>';
			echo '</div>';
			if (!in_array($tweet['from_user'], array_keys($recents))) {
				$recents[$tweet['from_user']] = array(
					'url' => 'http://twitter.com/' . $tweet['from_user'], 
					'image' => $tweet['profile_image_url']
				);
			}
		}
		if ($page > 1) {
			echo $html->link('<< Previous', '/members/tweets/' . ($page - 1));
		}
		echo ' ', $html->link('Next >>', '/members/tweets/' . ($page + 1))
		?>
	</div>
	<div class="yui-u">
		<h4>Tweeters</h4>
		<ul class="tweeters">
		<?php
			foreach($recents as $name => $meta) {
				echo '<li>', $html->image($meta['image']), '<p>', $html->link($name, $meta['url']), '</p></li>';
			}
		?>
		</ul>
		<h4>Feeds</h4>
		<ul class="tweeters">
			<li><img src="/images/interface/silk/feed.png"/><p><a href="http://search.twitter.com/search.atom?q=wmcoop">Atom</a></p></li>
			<li><img src="/images/interface/silk/feed.png"/><p><a href="http://search.twitter.com/search.rss?q=wmcoop">RSS</a></p></li>
		</ul>
		<a href="http://twitter.com"><img src="http://search.twitter.com/images/powered-by-twitter-badge.gif?1220915084" alt="Powered by Twitter"/></a>
	</div>
</div>
<style rel="stylesheet" type="text/css">
.tweet img {
	float: left;
	padding-top: 2px;
}
.tweet p {
	margin-left: 60px !important;
	font-size: 110%;
	padding: 0 !important;
}
.tweet p.date {
	font-size: 89%;
	font-family: Times;
	font-style: italic;
	color: gray !important;
}
.tweet {
	display: block;
	min-height: 52px;
	padding: 4px;
	border-bottom: 1px dashed #993300;
}

.tweeters {
	margin-left: 0;
}

.tweeters li {
	list-style-type: none;
}

.tweeters li p {
	margin-left: 3em !important;
	padding: 0 !important;
}

.tweeters img {
	float: left;
	margin-left: 1em;
	height: 16px;
	width: 16px;
}
</style>